#!/bin/bash

copy_flag=0
force_flag=0
kill_flag=""
stop_flag=0
dir_opt=""
xflag=0

while getopts cfksd:x OPT ; do

  case $OPT in

    "c") copy_flag=1 ;;

    "f") force_flag=1 ;;

    "k") kill_flag="--term" ;;

    "s") stop_flag=1 ;;

    "d") dir_opt="$OPTARG" ;;

    "x") x_flsg=1 ;;

  esac

done

shift `expr $OPTIND - 1`

if [ x$dir_opt != "x" -a -d $dir_opt ] ; then

  cd $dir_opt

fi

target=`ps h --ppid $1|awk '{ print $1 }'`

while : ; do

  chldpid=`ps h --ppid $target|awk '{ print $1 }'`

  if [ x$chldpid = "x" ] ; then

    break

  fi

  target=$chldpid
      

done
criu dump --leave-running -j -t $target 2>>./log 
